﻿using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Prism.Ioc;
using System.Threading.Tasks;
using ZoneLineNew.Services.Message;
using Prism.Services.Dialogs;

namespace ZoneLineNew.Common
{
    /// <summary>
    /// Prism Ioc
    /// </summary>
    public class PrismIocInfo
    {
        private static IMessageService _messageService;
        /// <summary>
        /// 消息弹框服务
        /// </summary>
        public static IMessageService MessageService
        {
            get
            {
                if (_messageService == null)
                    _messageService = ContainerLocator.Container.Resolve<IMessageService>();
                return _messageService;
            }
        }

        private static IDialogService _dialogService;
        /// <summary>
        /// Dialog弹框服务
        /// </summary>
        public static IDialogService DialogService
        {
            get
            {
                if (_dialogService == null)
                    _dialogService = ContainerLocator.Container.Resolve<IDialogService>();
                return _dialogService;
            }
        }


        private static IEventAggregator _eventAggregator;
        /// <summary>
        /// 发布订阅事件服务
        /// </summary>
        public static IEventAggregator EventAggregator
        {
            get
            {
                if (_eventAggregator == null)
                    _eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
                return _eventAggregator;
            }
        }

        /// <summary>
        /// 从IOC容器中获取对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T GetInstanceByIoc<T>()
        {
            return ContainerLocator.Container.Resolve<T>();
        }
    }
}
